package com.zq.ssmdemo.controller;


import com.github.pagehelper.PageInfo;
import com.zq.ssmdemo.pojo.Departments;
import com.zq.ssmdemo.pojo.Positions;
import com.zq.ssmdemo.service.IPositionsService;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * <p>
 * 职位信息表 前端控制器
 * </p>
 *
 * @author 张乔
 * @since 2024-06-09
 */
@Controller
@RequestMapping("/positions")
public class PositionsController {

@Resource
private IPositionsService positionsService;

    @GetMapping("/to/positions")
    public String toPositions() {
        return "positions";
    }


    @ResponseBody
    @GetMapping("/getPage/{page}/{limit}")
    public PageInfo<Positions> getPage(@PathVariable("page") Integer page,
                                       @PathVariable("limit") Integer limit) {

        PageInfo<Positions> departmentsPageInfo= positionsService.selectPage(page, limit);
        return departmentsPageInfo;
    }

    @ResponseBody
    @PostMapping("/add")
    public String add(@RequestBody Positions positions) {
        positionsService.add(positions);
        return "success";
    }
    @ResponseBody
    @PutMapping("/update")
    public String update(@RequestBody Positions positions) {
        positionsService.update(positions);
        return "success";
    }
    @ResponseBody
    @DeleteMapping("/deleteById/{id}")
    public String deleteById(@PathVariable("id") Integer id) {
        positionsService.deleteById(id);
        return "success";

    }

}
